#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/mman.h>

int main(int argc,char* argv[]){
	if(argc != 2){
		printf("command like:%s filename\n",argv[0]);
		return -1;
	}
	struct stat st;
	char* addr = NULL;
	int fd = open(argv[1], O_RDWR );
	if(fd<0){
		perror("open");
		return -1;
	}
	if(fstat(fd,&st)==-1){
		perror("stat");
		return -1;
	}
	if((addr = mmap(NULL,st.st_size,PROT_WRITE,MAP_SHARED,fd,0)) == -1){
		perror("mmap");
		return -1;
	}
	char * p = addr;
	int i = 0;
	for(;i<st.st_size;i++){
		if(*(p+i) == '\r'){
			*(p+i) = ' ';
		}
	}
	close(fd);
	munmap(addr,st.st_size);
}
